#include<bits/stdc++.h>
using namespace std;
int a[100010],b[100010];
int l=1,ll,n,ans,x,ma=-1;
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>x;
        a[x]++;
        b[x]++;
        ma=max(x,ma);
    }
    while(l<ma){
        while(l<ma-1&&a[l]==0)l++;
        ll=l+1;
        while(ll<ma&&(a[ll]==0||b[ll]==0))ll++;
        if(a[l]==0||a[ll]==0||b[ll]==0)break;
        a[l]--;
        b[ll]--;
    }
    for(int i=1;i<=ma;i++)ans+=a[i];
    cout<<ans;
    return 0;
}
